/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fxgreader;

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.lobobrowser.html.domimpl.HTMLDocumentImpl;
import org.lobobrowser.html.gui.HtmlPanel;
import org.lobobrowser.html.parser.DocumentBuilderImpl;
import org.lobobrowser.html.parser.InputSourceImpl;
import org.lobobrowser.html.test.SimpleHtmlRendererContext;
import org.lobobrowser.html.test.SimpleUserAgentContext;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

/**
 *
 * @author perkintang
 */
public class HtmlUtil {

private static Document document;

public static HtmlPanel getPanel(String link) throws SAXException, IOException{
    Logger.getLogger("").setLevel(Level.OFF);
    SimpleUserAgentContext ucontext = new SimpleUserAgentContext();
    HtmlPanel panel = new HtmlPanel();
    SimpleHtmlRendererContext rcontext = new SimpleHtmlRendererContext(panel,ucontext);
    ucontext.setExternalCSSEnabled(false);
    ucontext.setScriptingEnabled(false);
    DocumentBuilderImpl dbi = new DocumentBuilderImpl(ucontext, rcontext);
    document = dbi.createDocument(new InputSourceImpl(link));
    panel.setDocument(document, rcontext);
    return panel;
}

public static void loadPage() throws IOException, SAXException{
    ((HTMLDocumentImpl)document).load();
}

}
